package com.http;

import com.lidroid.xutils.HttpUtils;

import android.os.Handler;
import android.os.Message;

/**
 * @author py
 *网络请求基础类
 */
public class BaseController {
	public static HttpUtils httpUtils;
//	private CookieUtils cookieUtils;

	// protected HttpParams params;

	public BaseController() {
		if (httpUtils == null) {
			httpUtils = new HttpUtils();
			
			httpUtils.configCurrentHttpCacheExpiry(1);
		}

	}
	public static BaseController getInstance() {
		return null;
	}
	/**
	 * 
	 * @param handler
	 * @param flag
	 *            arg1用于标示数据条数等
	 * @param content
	 *            obj用于传递数据
	 * @param what
	 *            what用于标示那个方法
	 */
	protected void sendMsg(Handler handler, int what, int arg1, Object content) {
		if (handler == null)
			return;

		boolean is = handler.hasMessages(what);
		if (is) {
			handler.removeMessages(what);
		}
		Message message = new Message();
		message.what = what;
		message.arg1 = arg1;
		message.obj = content;
		handler.sendMessage(message);
	}

	/**
	 * 不需要传递数据只需要有个返回值标示的
	 * 
	 * @param handler
	 * @param arg1
	 * @param what
	 */
	protected void sendMsg(Handler handler, int what, int arg1) {
		if (handler == null)
			return;

		boolean is = handler.hasMessages(what);
		// if (is) {
		// handler.removeMessages(what);
		// }
		Message message = new Message();
		message.what = what;
		message.arg1 = arg1;
		handler.sendMessage(message);
	}

}
